/*
 * Copyright (c) 2020-2099 the original author or authors. All rights reserve.
 */
package org.tianyun.cloud.amqp.rabbitmq.annotation;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.AliasFor;
import org.tianyun.cloud.config.console.annotaion.ConsoleDiscovery;
import org.tianyun.cloud.config.refresh.smart.annotation.SmartScope;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Rabbit初始化注解，自动读取配置初始化ConncetionFactory
 *
 * @auther ebert_chan
 */
@Target(value = {ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Bean
@SmartScope
@ConfigurationProperties(ignoreInvalidFields = true)
@ConsoleDiscovery(namespace = ConsoleDiscovery.NAMESPACE_AMQP_RABBITMQ)
public @interface RabbitContainer {

    /**
     * @see ConfigurationProperties#prefix()
     * @see SmartScope#prefix()
     */
    @AliasFor(annotation = ConfigurationProperties.class, value = "prefix")
    String prefix() default "";

    /**
     * 定义ConnectionFactory Bean名称
     */
    @AliasFor(annotation = ConsoleDiscovery.class, value = "beanName")
    String connectionFactory();

    /**
     * 定义ListenerContainerFactory Bean名称，默认为空，不初始化
     */
    String containerFactory() default "";

    /**
     * 定义RabbitTemplate Bean名称，默认为空，不初始化
     */
    String rabbitTemplate() default "";

    /**
     * primary bean. 默认为false
     */
    boolean primary() default false;

}
